package com.utn.tp.integrador.notificaciones;

import com.utn.tp.integrador.R;
import com.utn.tp.integrador.activities.Main;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class NotificacionMensajeWeb {
	private static final int MENSAJE = 1;

	private static NotificationManager getManager(Context context) {

		NotificationManager mNotificationManager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		return mNotificationManager;
	}

	public static void notifyEnviado(Context context) {

		String tickerText = context.getString(R.string.enviado);

		Notification notification = new Notification(R.drawable.chat,
				tickerText, System.currentTimeMillis());

		Intent intent = new Intent(context, Main.class);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
				intent, 0);

		notification.setLatestEventInfo(context,
				context.getString(R.string.enviado),
				context.getString(R.string.enviado), pendingIntent);

		getManager(context).notify(MENSAJE, notification);
	}

	public static void notifyError(Context context) {
		String tickerText = context.getString(R.string.mensaje_error);

		Notification notification = new Notification(R.drawable.chat,
				tickerText, System.currentTimeMillis());
		Intent intent = new Intent(context, Main.class);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
				intent, 0);

		notification.setLatestEventInfo(context,
				context.getString(R.string.mensaje_error),
				context.getString(R.string.mensaje_error), pendingIntent);

		getManager(context).notify(MENSAJE, notification);
	}

	public static void notifyRecibido(Context context) {

		String tickerText = context.getString(R.string.recibido);

		Notification notification = new Notification(R.drawable.chat,
				tickerText, System.currentTimeMillis());

		Intent intent = new Intent(context, Main.class);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
				intent, 0);

		notification.setLatestEventInfo(context,
				context.getString(R.string.recibido),
				context.getString(R.string.recibido), pendingIntent);

		getManager(context).notify(MENSAJE, notification);
	}

}
